<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use App\Scopes\IsDelScope;

class ServiceModel extends BaseModel {

    protected static function booted()
    {
        parent::booted();
    }

    protected $table = "dtrd_ent_rd_service_package";
    protected $primaryKey = "data_id";

    const CREATED_AT = 'create_time';
    const UPDATED_AT = null;

    protected $casts = [
        'create_time' => 'datetime:Y-m-d H:i:s',
    ];

    const PERIOD_UNIT = [
        1 => '天',
        2 => '个月',
        3 => '年',
        4 => '周',
    ];

    protected $hidden = ['is_del'];
    protected $fillable = [];

    protected $appends = [
        'format_service_period'
    ];

    public function getPeriodUnitAttribute($value)
    {
        return self::PERIOD_UNIT[$value] ?? '天';
    }

    public function getFormatServicePeriodAttribute()
    {
        return "{$this->package_service_period}{$this->period_unit}";
    }
}
